package com.tech.customer

import org.apache.spark.sql.SparkSession
import org.apache.spark.sql.streaming.StreamingQueryListener

class MyStreamingQueryListener(val spark: SparkSession, val loadResourceManager: LoadResourceManager) extends StreamingQueryListener {
  override def onQueryStarted(event: StreamingQueryListener.QueryStartedEvent): Unit = {
    //    println("Query started:" + event.id)
  }

  override def onQueryProgress(event: StreamingQueryListener.QueryProgressEvent): Unit = {
//        println("Query made progress: " + event.progress)
//    println(this.loadResourceManager.httpMapBroadcast.value)
//    println(System.currentTimeMillis())
    this.loadResourceManager.unPersist()
    this.loadResourceManager.load(spark)
//    println(this.loadResourceManager.retaileventSchemaMapBroadcast.value)
//    println(this.loadResourceManager.customerSchemaMapBroadcast.value)
//    println(this.loadResourceManager.ruleMapBroadcast.value)
//    println(System.currentTimeMillis())
    //    }
  }

  override def onQueryTerminated(event: StreamingQueryListener.QueryTerminatedEvent): Unit = {
    //    println("Query terminated: " + event.id)
  }
}
